import java.util.Date;


public class Run extends StopWatch{

	static private int globalRunID = 0;
	public int id;
	public Date startDate;
	public Date endDate;
	public long runLength;
	public long gainXP;
	public long gainGOLD;
	public String startXP;
	public String startGOLD;
	public String endXP;
	public String endGOLD;

	Run(String startXP, String startGOLD, String endXP, String endGOLD){
		id = globalRunID;
		globalRunID++;
		this.startXP = startXP;
		this.startGOLD = startGOLD;
		this.endXP = endXP;
		this.endGOLD = endGOLD;	
	}
	
	Run(Date startDate, Date endDate, String startXP, String startGOLD, String endXP, String endGOLD){
		id = globalRunID;
		globalRunID++;
		this.startDate = startDate;
		this.endDate = endDate;
		this.runLength = endDate.getTime() - startDate.getTime();
		this.startXP = startXP;
		this.startGOLD = startGOLD;
		this.endXP = endXP;
		this.endGOLD = endGOLD;	
//		if(!endGOLD.equals("") && !startGOLD.equals("") && )
		this.gainGOLD = Long.parseLong(endGOLD) - Long.parseLong(startGOLD);
		this.gainXP = Long.parseLong(endXP) - Long.parseLong(startXP);
		
	}
	
	public String toString(){
		String result = "";
		System.out.println("run nr: " + id);
		System.out.println("started: " + startDate.toString());
		System.out.println("ended: " + endDate.toString());
		System.out.println("length: " + runLength);
		System.out.println("gainXP: " + gainXP);
		System.out.println("gainGOLD: " + gainGOLD);
		
		
		return result;
	}
	
//	 Element startStatus = new Element("startStatus");
//	 Element startXP = new Element("XP");
//	 startXP.addContent("1111");
//	 Element startGOLD = new Element("GOLD");
//	 startGOLD.addContent("9999");
//	 startStatus.addContent(startXP);
//	 startStatus.addContent(startGOLD);
//	 
//	 Element endStatus = new Element("endStatus");
//	 Element endXP = new Element("XP");
//	 endXP.addContent("2222");
//	 Element endGOLD = new Element("GOLD");
//	 endGOLD.addContent("18000");
//	 endStatus.addContent(endXP);
//	 endStatus.addContent(endGOLD);
//	 
//
//	 run.addContent(startStatus);
//	 run.addContent(endStatus);
//	 
//	 runList.addContent(run);
//
//	 //add status to statuslist
//	 build.addContent(runList);
//	 builds.addContent(build);
//	
//	 // add everything to root
//	 dokument.getRootElement().addContent(programStatus);
//	 dokument.getRootElement().addContent(builds);
//	
//	 XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
//	 FileOutputStream output = new FileOutputStream("file.xml");
//	 outputter.output(dokument, output);
//	 System.out.println("file written");
}
